home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / tracker-4.13.lha / tracker / dump_song.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-15  |  4.0 KB  |  177 lines

  1. /* dump_song.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4.  
  5. /* $Id: dump_song.c,v 4.9 1995/02/14 04:02:28 espie Exp $
  6.  * $Log: dump_song.c,v $
  7.  * Revision 4.9  1995/02/14  04:02:28  espie
  8.  * Nothing
  9.  *
  10.  * Revision 4.9  1995/02/14  04:02:28  espie
  11.  * Nothing
  12.  *
  13.  * Revision 4.8  1995/02/06  14:50:47  espie
  14.  * Changed sample_info.
  15.  *
  16.  * Revision 4.8  1995/02/06  14:50:47  espie
  17.  * Changed sample_info.
  18.  *
  19.  * Revision 4.7  1995/02/01  20:41:45  espie
  20.  * Added color.
  21.  *
  22.  * Revision 4.6  1995/02/01  16:39:04  espie
  23.  * Includes moved to defs.h
  24.  *
  25.  * Revision 4.6  1995/02/01  16:39:04  espie
  26.  * Includes moved to defs.h
  27.  *
  28.  * Revision 4.0  1994/01/11  17:46:01  espie
  29.  * Use virtual windows.
  30.  * No more call to run_in_fg(), use begin_info result instead.
  31.  * Added instrument name as shown per display.c.
  32.  * Use info facility.
  33.  * Amiga support.
  34.  * Very small bug with volume (Lawrence).
  35.  * Added finetune display.
  36.  * Added bg/fg test.
  37.  */
  38.  
  39. #include "defs.h"
  40.  
  41. #include <ctype.h>
  42.  
  43. #include "song.h"
  44. #include "extern.h"
  45. #include "channel.h"
  46.  
  47. ID("$Id: dump_song.c,v 4.9 1995/02/14 04:02:28 espie Exp $")
  48.  
  49. LOCAL void *handle = 0;
  50. LOCAL char buffer[80];
  51. extern char instname[];
  52.  
  53. /***
  54.  *
  55.  *  dump_block/dump_song:
  56.  *  shows most of the readable info
  57.  *  concerning a module on the screen.
  58.  *
  59.  ***/
  60.  
  61. LOCAL void dump_block(b)
  62. struct block *b;
  63.    {
  64.    int i, j;
  65.  
  66.    for (i = 0; i < BLOCK_LENGTH; i++)
  67.       {
  68.       for (j = 0; j < NUMBER_TRACKS; j++)
  69.          {
  70.          sprintf(buffer,"%8d%5d%2d%4d", b->e[j][i].sample_number,
  71.             b->e[j][i].pitch, b->e[j][i].effect,
  72.             b->e[j][i].parameters);
  73.          infos(handle, buffer);
  74.          }
  75.       info(handle, "");
  76.       }
  77.    }
  78.  
  79. /* make_readable(s):
  80.  * transform s into a really readable string */
  81.  
  82. LOCAL void make_readable(s)
  83. char *s;
  84.    {
  85.    char *t, *orig;
  86.  
  87.    if (!s)
  88.       return;
  89.  
  90.    orig = s;
  91.    t = s;
  92.  
  93.       /* get rid of the st-xx: junk */
  94.    if (strncmp(s, "st-", 3) == 0 || strncmp(s, "ST-", 3) == 0)
  95.       {
  96.       if (isdigit(s[3]) && isdigit(s[4]) && s[5] == ':')
  97.          s += 6;
  98.       }
  99.    while (*s)
  100.       {
  101.       if (isprint(*s))
  102.          *t++ = *s;
  103.       s++;
  104.       }
  105.    *t = '\0';
  106.    while (t != orig && isspace(t[-1]))
  107.       *--t = '\0';
  108.    }
  109.  
  110. void dump_song(song)
  111. struct song *song;
  112.    {
  113.    int i, j;
  114.    int maxlen;
  115.    static char dummy[1];
  116.  
  117.    
  118.    handle = begin_info(song->title);
  119.    if (!handle)
  120.       return;
  121.  
  122.    dummy[0] = '\0';
  123.    maxlen = 0;
  124.    for (i = 1; i < NUMBER_SAMPLES; i++)
  125.       {
  126.       if (!song->samples[i]->name)
  127.          song->samples[i]->name = dummy;
  128.       make_readable(song->samples[i]->name);
  129.       if (maxlen < strlen(song->samples[i]->name))
  130.          maxlen = strlen(song->samples[i]->name);
  131.       }
  132.    for (i = 1; i < NUMBER_SAMPLES; i++)
  133.       {
  134.       if (song->samples[i]->start || strlen(song->samples[i]->name) > 2)
  135.          {
  136.          char s[3];
  137.          
  138.          s[0] = instname[i];
  139.          s[1] = ' ';
  140.          s[2] = 0;
  141.          infos(handle, s);
  142.          infos(handle, song->samples[i]->name);
  143.          for (j = strlen(song->samples[i]->name); j < maxlen + 2; j++)
  144.             infos(handle, " ");
  145.          if (song->samples[i]->start)
  146.             {
  147.             sprintf(buffer, "%5d", song->samples[i]->length);
  148.             infos(handle, buffer);
  149.             if (song->samples[i]->rp_length > 2)
  150.                {
  151.                sprintf(buffer, "(%5d %5d)", 
  152.                   song->samples[i]->rp_offset, 
  153.                   song->samples[i]->rp_length);
  154.                infos(handle, buffer);
  155.                }
  156.             else
  157.                infos(handle, "             ");
  158.             if (song->samples[i]->volume != MAX_VOLUME)
  159.                {
  160.                sprintf(buffer, "%3d", song->samples[i]->volume);
  161.                infos(handle, buffer);
  162.                }
  163.             else 
  164.                infos(handle, "   ");
  165.             if (song->samples[i]->finetune)
  166.                {
  167.                sprintf(buffer, "%3d", song->samples[i]->finetune);
  168.                infos(handle, buffer);
  169.                }
  170.             }
  171.          info(handle, "");
  172.          }
  173.       }
  174.    end_info(handle);
  175.    handle = 0;
  176.    }
  177.